import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_audit_app/routes/fluro_navigator.dart';
import 'package:flutter_audit_app/routes/router_path.dart';
import 'package:flutter_audit_app/utils/sputil_key.dart';


bool isLargeScreen;

//启动页面
///执行顺序SplashPage构造——> _SplashPageState构造——> initState()——> build()
class SplashPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  @override
  void initState() {
    Future.delayed(Duration(seconds: 2)).then(
      (value) => {NavigatorUtils.push(context, RouterPath.login, clearStack: true)},
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // ScreenUtil.init(context, width: 1920.0, height: 1200.0);
    setDesignWHD(640.0, 360.0, density: 3);
    isLargeScreen = (MediaQuery.of(context).size.width >= 600 ?? false);
    SpUtil.putBool(SpKey.isLargeScreen, isLargeScreen);

    return Scaffold(
      body: OrientationBuilder(
        builder: (context, orientation) {
          //判断屏幕宽度
          // print("isLargeScreen = $isLargeScreen");
          SystemChrome.setPreferredOrientations([
            DeviceOrientation.landscapeLeft,
            DeviceOrientation.landscapeRight
          ]);
          return Image.asset(
            'assets/images/bg_splash.png',
            width: MediaQuery.of(context).size.width,
            height: MediaQuery.of(context).size.height,
            fit: BoxFit.cover,
          );
        },
      ),
    );
  }
}
